#include <iostream>
#include <memory>
#include <vector>
using namespace std;
class Product {
public:
    Product(const std::string& name) : name(name) {}
    void display() const { std::cout << "Product: " << name << std::endl; }
private:
    std::string name;
};

int main() {
    std::shared_ptr<Product> product = std::make_shared<Product>("Laptop");

    cout<<product.use_count()<<endl;
    
    // 多个组件共享产品对象
    std::vector<std::shared_ptr<Product>> products;
    products.push_back(product);

    cout<<product.use_count()<<endl;

    products.emplace_back(product);
    cout<<product.use_count()<<endl;
    
    for (const auto& p : products) {
        p->display();
    }

    return 0;
}

